package com.lmz.order.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单确认页需要的数据
 */
public class OrderConfirmVo {

    //收获地址  ums_member_receive_address
    @Getter
    @Setter
    private List<MemberAddressVo> address;

    //选中的购物项
    @Getter
    @Setter
    private List<OrderItemVo> items;

    //积分
    @Getter
    @Setter
    private Integer integration;

    //token防止重复提交
    @Getter
    @Setter
    private String orderToken;

    @Getter
    @Setter
    private Map<Long, Boolean> stocks;

    @Getter
    @Setter
    private BigDecimal payPrice;

    //private BigDecimal total;
    //应付的价格
    //private BigDecimal payPrice;

    public Integer getCount() {
        Integer i = 0;
        if (this.items != null) {
            for (OrderItemVo item : this.items) {
                i += item.getCount();
            }
        }
        return i;
    }

    public BigDecimal getTotal() {
        BigDecimal bigDecimal = new BigDecimal("0");
        if (this.items != null) {
            for (OrderItemVo item : this.items) {
                BigDecimal price = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                bigDecimal = bigDecimal.add(price);
            }
        }
        return bigDecimal;
    }


}